//logs.js
/*
var Stomp = require('../../utils/stomp.js').Stomp;
Stomp.setInterval = function (interval, f) {
  return setInterval(f, interval);
};
Stomp.clearInterval = function (id) {
  return clearInterval(id);
};
var client = Stomp.over(ws);
*/
Page({
  data: {
    gtime:'***',
    
  },
  
  getTime: function () {
    var _self = this
    wx.request({
      url: 'https://www.shineyue.com/service/api/gettime',
      data: {

      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        //console.log(res.data)
        //console.log(res.data.gtime)
        _self.setData({
          gtime:res.data.gtime
        })
      }
    })
  },
  fresh: function(){
    setInterval(this.getTime, 1000)
  },

  connect: function(){
    wx.connectSocket({
      url: 'wss://www.shineyue.com/service/endpointShine'
    })

    wx.onSocketOpen(function (res) {
      console.log('WebSocket连接已打开！')
    })

    wx.onSocketError(function (res) {
      console.log('WebSocket连接打开失败，请检查！')
    })
  },
  disconnection:function(){
    wx.onSocketOpen(function () {
      wx.closeSocket()
    })

    wx.onSocketClose(function (res) {
      console.log('WebSocket 已关闭！')
    })
  },
///////////////////////////////////////////////////////
  connectWebsocket: function () {
    wx.connectSocket({
      url: 'wss://www.shineyue.com/service/webSocketServer.action',
      data: {
      },
      header: {
        'content-type': 'application/json'
      },
      method: "GET"
    })
    wx.onSocketOpen(function (res) {
      console.log('WebSocket连接已打开！')
    })
    wx.onSocketError(function (res) {
      console.log('WebSocket连接打开失败，请检查！')
    })
    wx.onSocketMessage(function (res) {
      console.log('收到服务器内容：' + res.data)
    })
  },
  disconnectWebsocket:function()  {
    this.disconnection()
  }
})
